package name.flurl.android.tt_news4android;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;

import name.flurl.android.tt_news4android.util.ObjectSerializer;

import android.content.SharedPreferences;
import android.util.Log;

public class Tt_news4AndroidSharedPreferences implements SharedPreferences {

	private SharedPreferences mSp = null;

	public Tt_news4AndroidSharedPreferences(SharedPreferences mSp) {
		this.mSp = mSp;
	}

	public ArrayList<String[]> getSites(String key) {
		String str = mSp.getString(key, "");
		Log.i("tt_news getsites", str + "+++");
		ArrayList<String[]> list = new ArrayList<String[]>();
		if (!str.equals("")) {
			try {
				list = (ArrayList<String[]>) ObjectSerializer.deserialize(str);
			} catch (IOException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
		}
		return list;
	}

	@Override
	public boolean contains(String key) {
		return mSp.contains(key);
	}

	@Override
	public Editor edit() {
		return mSp.edit();
	}

	@Override
	public Map<String, ?> getAll() {
		return mSp.getAll();
	}

	@Override
	public boolean getBoolean(String key, boolean defValue) {
		return mSp.getBoolean(key, defValue);
	}

	@Override
	public float getFloat(String key, float defValue) {
		return mSp.getFloat(key, defValue);
	}

	@Override
	public int getInt(String key, int defValue) {
		return mSp.getInt(key, defValue);
	}

	@Override
	public long getLong(String key, long defValue) {
		return mSp.getLong(key, defValue);
	}

	@Override
	public String getString(String key, String defValue) {
		return mSp.getString(key, defValue);
	}

	@Override
	public void registerOnSharedPreferenceChangeListener(
			OnSharedPreferenceChangeListener listener) {
		mSp.registerOnSharedPreferenceChangeListener(listener);
	}

	@Override
	public void unregisterOnSharedPreferenceChangeListener(
			OnSharedPreferenceChangeListener listener) {
		mSp.unregisterOnSharedPreferenceChangeListener(listener);

	}

}
